﻿using Api.Core.Model;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Api.Core.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    //[Authorize]
    public class BaseController : ControllerBase
    {

        protected BaseResponse<T> Result<T>(T t, StatusCode code,string msg)
        {
            if (string.IsNullOrEmpty(msg))
            {
                switch (code)
                {
                    case Model.StatusCode.Success:
                        msg = "操作成功";
                        break;
                    case Model.StatusCode.ParamsNull:
                        msg = "参数为空";
                        break;
                }
            }
            return BaseResponse<T>.GetResponse(t, code, msg);
        }

        protected BaseResponse<T> Result<T>(T t)
        {

           return this.Result<T>(t,Model.StatusCode.Success,"");
        }
    }
}